home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <ctype.h>
- #include <string.h>
-
- FILE *fpic,*fpif,*fpo,*fopen();
- unsigned char s[1025],filnam[100],tag[100],*ptr;
- int i,errflag,yk;
-
- main(argc,argv)
- int argc;
- unsigned char **argv;
- {
- int argk,c,state,ip;
- long lc;
- register char **p;
- argk = argc;
- if (argk < 3)
- {
- printf("usage: ejoin control_file output_file\n ");
- exit(0);
- }
- p=argv;
- p++;
- fpic= fopen(*p,"r");
- if (fpic == NULL)
- {
- printf("\nCannot open %s\n",*p);
- exit(1);
- }
- p++;
- fpo = fopen(*p,"w");
- if (fpo == NULL)
- {
- printf("\nCannot open %s\n",*p);
- exit(1);
- }
- while (!feof(fpic))
- {
- fgets(s,100,fpic);
- if(feof(fpic))break;
- s[strlen(s)-1] = 0;
- ptr = strtok(s," \t");
- strcpy(filnam,ptr);
- ptr = strtok(NULL," \t");
- if (ptr != NULL) strcpy(tag,ptr);
- fpif = fopen(filnam,"r");
- if (fpic == NULL)
- {
- printf("\nCannot open %s\n",filnam);
- exit(1);
- }
- while (!feof(fpif))
- {
- fgets(s,1024,fpif);
- if(feof(fpif))break;
- s[strlen(s)-1] = 0;
- fprintf(fpo,"%s",s);
- if (ptr !=NULL) fprintf(fpo,"%s/",tag);
- fprintf(fpo,"\n");
- }
- fclose(fpif);
- }
- fclose(fpic);
- fclose(fpo);
- }
-